﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Data;
using EazyCMS.BLL;

namespace EazyCMS.Web.tools
{
    /// <summary>
    /// GetCJData 的摘要说明
    /// </summary>
    public class GetCJData : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string stuid = context.Request["stuid"];
             string FrameHtml = "";
             try
             {
                 string sql0 = "";
                 string sql = "select top(1)a.*,b.user_name from  dbo.dt_student_score a left join dbo.dt_student_info b on a.user_id=b.id where a.user_id='" + stuid+ "' order by a.add_time desc";
                 DataTable dt = GetStuStore.GetCjs(sql);
                 FrameHtml += "<span style='font-size:14px; color:#20b1ff; margin-left:274px; line-height:83px;' >" + dt.Rows[0]["user_name"].ToString() + "</span>";
FrameHtml+="<span style='font-size:14px;' >您好</span>";
FrameHtml+="<span  style='font-size:14px;'>您的成绩查询结果如下：</span>";

FrameHtml+="<table width='447px' height='240px'  border='1' bordercolor='#87d4fe' cellspacing='0' cellpadding='0' style='text-align:center; margin-left:270px; margin-top:-20px;'border-collapse: collapse; class='ls'>";
  FrameHtml+="<tr>";
   FrameHtml+=" <td style='width:142px;'>语文2</td>";
   FrameHtml += " <td style='width:305px;'>" + dt.Rows[0]["yuwen"].ToString() + "分</td>";
  FrameHtml+="</tr>";
  FrameHtml+="<tr>";
   FrameHtml+=" <td style='width:142px;'>数学</td>";
   FrameHtml += "<td><span style='width:305px;'>" + dt.Rows[0]["shuxue"].ToString() + "分</span></td>";
  FrameHtml+="</tr>";
  FrameHtml+="<tr>";
    FrameHtml+="<td style='width:142px;'>英语</td>";
    FrameHtml += "<td><span style='width:305px;'>" + dt.Rows[0]["yingyu"].ToString() + "分</span></td>";
  FrameHtml+="</tr>";
  FrameHtml+="<tr>";
   FrameHtml+=" <td style='width:142px;'>政治</td>";
   FrameHtml += "<td><span style='width:305px;'>" + dt.Rows[0]["zhengzhi"].ToString() + "分</span></td>";
  FrameHtml+="</tr>";
  FrameHtml+="<tr>";
   FrameHtml+=" <td style='width:142px;'>历史</td>";
   FrameHtml += " <td><span style='width:305px; text-align:center;'>" + dt.Rows[0]["lishi"].ToString() + "分</span></td>";
  FrameHtml+="</tr>";
  FrameHtml+="<tr>";
    FrameHtml+="<td style='width:142px;'>物理</td>";
    FrameHtml += "<td><span style='width:305px;'>" + dt.Rows[0]["wuli"].ToString() + "分</span></td>";
  FrameHtml+="</tr>";
  FrameHtml+="<tr>";
    FrameHtml+="<td style='width:142px;'>化学</td>";
    FrameHtml += "<td><span style='width:305px;'>" + dt.Rows[0]["huaxue"].ToString() + "分</span></td>";
  FrameHtml+="</tr>";
  FrameHtml+="<tr>";
    FrameHtml+="<td style='width:142px; color:#F00' >总分</td>";
    FrameHtml += " <td  style='color:#F00'>" + (Convert.ToInt32(dt.Rows[0]["yuwen"]) + Convert.ToInt32(dt.Rows[0]["shuxue"]) + Convert.ToInt32(dt.Rows[0]["yingyu"]) + Convert.ToInt32(dt.Rows[0]["zhengzhi"]) + Convert.ToInt32(dt.Rows[0]["lishi"]) + Convert.ToInt32(dt.Rows[0]["wuli"]) + Convert.ToInt32(dt.Rows[0]["huaxue"])).ToString() + "分</td>";
  FrameHtml+="</tr>";
  FrameHtml += "</table>";
             }
             catch { 
             
             }
             context.Response.Write(new JavaScriptSerializer().Serialize(FrameHtml));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}